package com.mark.anto.service.impl;

import com.mark.anto.service.CalculateService;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;

import java.util.stream.Stream;

/**
 * @Description: Java 8 Lambda 实现 {@link CalculateService}
 * @Author: Mark
 * @CreateDate: 2019/9/1 9:08
 * @Version: 3.00.001
 * @Copyright : 豆浆油条个人非正式工作室
 */
@Profile(CalculateService.JAVA8_PROFILE_VALUE)
@Service
public class CalculateServiceImplByJava8 implements CalculateService {

    @Override
    public Integer sum(Integer... values) {
        System.out.println("Java 8 Lambda 实现");
        return Stream.of(values).reduce(0, Integer::sum);
    }
}
